Skip to content

fix(update): replace active binary during self-update#84

Closed
ysyneu wants to merge 1 commit into
feat/ai-srefrom
audit-fix/audit-20260714-update-active-bin
Closed

fix(update): replace active binary during self-update#84
ysyneu wants to merge 1 commit into
feat/ai-srefrom
audit-fix/audit-20260714-update-active-bin

Conversation

@ysyneu

@ysyneu ysyneu commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • install self-updates over the currently executing binary path on Unix
  • verify the same absolute binary reports the expected release before declaring success
  • keep Windows behavior and messaging unchanged

Audit evidence

Production session sess_6cLDsewKHez6eMaGjU5BDT ran fduty update, but the installer wrote ~/.local/bin/flashduty while the active entry remained ~/.flashduty/bin/fduty v1.3.6.

Verification

  • make GOLANGCI_LINT=/tmp/fc-safari-audit-tools/golangci-lint-current (fmt, lint, race tests, build)
  • go test -race ./internal/cli -run 'TestRunInstaller(UpdatesInvokedBinary|RejectsShadowedInstall)' -count=1\n- /simplify --uncommitted\n- /review-to-main --uncommitted\n- /review-to-main

@ysyneu ysyneu left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review blockers:P1)更新流程没有强制 installer 使用已检查的 expected version,继承 FLASHDUTY_VERSION 或 latest 漂移会先替换/降级活动二进制再报错;P1)installer 直接从临时目录覆盖活动文件,验证发生在替换后,跨文件系统不原子且无回滚;P2)sudo mv 可能把 root-owned 文件变为调用用户所有;P3)测试用假 sh 直接写目标,未覆盖真实 install.sh 的 mv/权限/回滚语义。应在目标目录同文件系统 staging,验证 staged binary 后保留 owner/mode 原子替换,并固定 expected version。当前不能合并。

@ysyneu

ysyneu commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

关闭:当前方案在验证前直接替换活动二进制,存在版本漂移、跨文件系统非原子覆盖、无回滚和 sudo 所有权风险。runner 场景已改走“runner owns CLI,禁止自更新”的更小边界;standalone 自更新若继续做,需重新设计同目录 staging、预验证、保留 owner/mode、原子 rename。

@ysyneu ysyneu closed this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant